var pageParam = {};

$(function() {
	$('#vue_vm_list').hide();
});

function findElderPay() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list').hide();
	var searchVal = $('#searchVal').val();
	var startYear = $('#startYear').val();
	var startMonth = $('#startMonth').val();
	var startDay = $('#startDay').val();
	var endYear = $('#endYear').val();
	var endMonth = $('#endMonth').val();
	var endDay = $('#endDay').val();
	var startTime = getStandardDay(startYear, startMonth, startDay);
	var endTime = getStandardDay(endYear, endMonth, endDay);
	
	if(isEmpty(startYear)) {
		alert('请输入开始年');
		return;
	}
	if(isEmpty(startMonth)) {
		alert('请选择开始月');
		return;
	}
	if(isEmpty(startDay)) {
		alert('请选择开始日');
		return;
	}
	if(isEmpty(endYear)) {
		alert('请输入结束年');
		return;
	}
	if(isEmpty(endMonth)) {
		alert('请选择结束月');
		return;
	}
	if(isEmpty(endDay)) {
		alert('请选择结束日');
		return;
	}
	if(isEmpty(startTime)) {
		alert('请输入开始时间');
		return;
	}
	if(isEmpty(endTime)) {
		alert('请输入结束时间');
		return;
	}
	
	find_basic_by_json(path+'/elderPayRecord/findByDate', {dateSince: startTime, dateEnd: endTime, searchVal: searchVal}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		var totalCount = 0;
		var totalPayMoney = 0;
		for(var i=0; i<response.data.length; i++) {
			totalCount += 1;
			totalPayMoney += response.data[i].payMoney;
		}
		
		var total = {totalCount: totalCount, totalPayMoney: totalPayMoney};
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				total: total,
				todos: response.data
			},
			methods: {
				elderPayReturnApply:function(total, todo) {
					if(confirm('确定要申请退费吗？')) {
						save_basic(path+'/elderPayReturnApply/elderPayReturnApply',
						{applyModuleForm:{payRecordIds:[todo.elderPayRecordId], money:todo.returnMoney,
							reasonDesc: todo.reasonDesc, createId:getLoginedUser().staffId}},
						function() {
							total.totalCount -= 1;
							total.totalPayMoney -= todo.payMoney;
							$('#' + todo.elderPayRecordId + '_row').remove();
							alert('申请提交成功');
						});
					}
				}
			}
		});
		
		$('#vue_vm_list').show();
	});
}